<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <h1></h1>
  <script>

 



    //为什么要先调用一次能  因为在调用函数之前有个写死的时间诶 要把那个覆盖掉
    gettime()
    function gettime() {
      //现在时间
      const date = new Date()
      //未来时间
      const date1 = +new Date(`2023-10-1 00:00:00`)
      //剩余毫秒数
      let time = (date1 - date) / 1000
      //换算
      let d = parseInt(time / 60 / 60 / 24)
     let h = parseInt(time / 60 / 60 % 24)
      h = h <= 10 ? '0' + h : h
     let m = parseInt(time / 60 % 60)
      m = m <= 10 ? '0' + m : m
     let s = parseInt(time % 60)
      s = s <= 10 ? '0' + s : s

      document.querySelector('h1').innerHTML = `距离国庆还有${d+'日'+ h +'时'+ m +'分'+s+'秒'}`
      
    }
    setInterval(gettime,1000)
  </script>
</body>
</html>